#!/usr/bin/env python2.7.14
# -*- coding: utf-8 -*-
"""
Created on 18-12-31

@author: 260190

@description:在数据库中创建新表
"""
import pymysql

server = '127.0.0.1'
user = 'root'
password = 'geli*2013'
conn = pymysql.connect(server, user, password, database='twbg')  # 获取连接
cursor = conn.cursor()  # 获取游标
# "**ENGINE=InnoDB DEFAULT CHARSET=utf8**"-创建表的过程中增加这条，中文就不是乱码

# 删除表
# cursor.execute("""DROP TABLE record202008""")

# 创建表
creat_sql = """
CREATE TABLE record202008(
Id int primary key auto_increment,
ip VARCHAR(45),
date VARCHAR(45),
time VARCHAR(45),
thresh VARCHAR(45),
status VARCHAR(45),
errmsg VARCHAR(2500),
exception VARCHAR(2841)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8"""
cursor.execute(creat_sql)

# 提交数据，才会写入表格
conn.commit()
# 关闭游标关闭数据库
cursor.close()
conn.close()
